<template>
	<div class="home">
		<!-- <img alt="Vue logo" src="../assets/logo.png"> -->
		{{aa}}
		<button @click="addUser">添加</button>
		<ul>
			<li v-for="user in users" :key="user.id">
				{{user.id}}.{{user.name}},{{user.age}}
			</li>
		</ul>
	</div>
</template>

<script>
	// @ is an alias to /src
	
	import {
		mapState
	} from 'vuex';
	let uid = 0;

	export default {
		name: 'Home',
		components: {
			
		},
		data() {
			return {};
		},
		computed: {
			...mapState({
				users: (state) => {
					return state.users;
				}
			}),
			aa: () => {
				return "asdasd-123"
			}
		},
		methods: {
			addUser() {
				this.$store.commit("addUser", {
					id: ++uid,
					name: "cjc",
					age: 12
				});
			}
		}
	}
</script>
